import 'package:flutter/material.dart';
import 'package:flutterapp/myicon/MyTabIcons.dart';
import 'tabs/Quanzi.dart';
import 'tabs/Haoyue.dart';
import 'tabs/Fabu.dart';
import 'tabs/Haowu.dart';
import 'tabs/Wode.dart';

class Tabs extends StatefulWidget {
  final index;
  Tabs({Key? key, this.index = 0}) : super(key: key);

  _TabsState createState() => _TabsState(this.index);
}

class _TabsState extends State<Tabs> {
  int _currentIndex;
  _TabsState(this._currentIndex);
  List _pageList = [
    Quanzi(),
    HaoYue(),
    Fabu(),
    Haowu(),
    Wode(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: this._pageList[this._currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex, //配置对应的索引值选中
        onTap: (int index) {
          setState(() {
            //改变状态
            this._currentIndex = index;
          });
        },
        iconSize: 36.0, //icon的大小q
        fixedColor: new Color.fromRGBO(35, 218, 212, 1.0),
        type: BottomNavigationBarType.fixed, //配置底部tabs可以有多个按钮
        items: [
          BottomNavigationBarItem(icon: Icon(MyTabIcons.quanzi), label: "圈子"),
          BottomNavigationBarItem(icon: Icon(MyTabIcons.juhui), label: "好约"),
          BottomNavigationBarItem(icon: Icon(MyTabIcons.juhui), label: "发布"),
          BottomNavigationBarItem(icon: Icon(MyTabIcons.haowu), label: "好物"),
          BottomNavigationBarItem(icon: Icon(MyTabIcons.wode), label: "我的")
        ],
      ),
      floatingActionButton: Container(
        height: 60,
        width: 60,
        padding: EdgeInsets.all(8),
        margin: EdgeInsets.only(top: 35),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(40),
          color: Colors.white,
        ),
        child: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: () {
            setState(() {
              //改变状态
              this._currentIndex = 2;
            });
          },
          backgroundColor: Color.fromRGBO(35, 218, 212, 1.0),
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    );
  }
}
